home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / DemoApplet.java < prev    next >
Text File  |  1998-09-15  |  2KB  |  78 lines

  1. /*
  2.  * @(#)DemoApplet.java     1.1 98/06/16
  3.  *
  4.  * (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
  5.  * (C) Copyright IBM Corp. 1996 - All Rights Reserved
  6.  *
  7.  * Portions copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  8.  *
  9.  *   The original version of this source code and documentation is copyrighted
  10.  * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
  11.  * materials are provided under terms of a License Agreement between Taligent
  12.  * and Sun. This technology is protected by multiple US and International
  13.  * patents. This notice and attribution to Taligent may not be removed.
  14.  *   Taligent is a registered trademark of Taligent, Inc.
  15.  *
  16.  * Permission to use, copy, modify, and distribute this software
  17.  * and its documentation for NON-COMMERCIAL purposes and without
  18.  * fee is hereby granted provided that this copyright notice
  19.  * appears in all copies. Please refer to the file "copyright.html"
  20.  * for further important copyright and licensing information.
  21.  *
  22.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  23.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  24.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  25.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  26.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  27.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  28.  *
  29.  */
  30.  
  31.  
  32. import java.applet.Applet;
  33. import java.awt.event.*;
  34. import java.awt.*;
  35.  
  36. public abstract class DemoApplet extends java.applet.Applet implements ActionListener
  37. {
  38.     private Button   demoButton;
  39.     private Frame    demoFrame;
  40.  
  41.     public abstract Frame createDemoFrame(DemoApplet applet);
  42.  
  43.     //Create a button that will display the demo
  44.     public void init()
  45.     {
  46.         setBackground(Color.white);
  47.         demoButton = new Button("Demo");
  48.     demoButton.addActionListener(this);
  49.         demoButton.setBackground(Color.yellow);
  50.         add( demoButton );
  51.     }
  52.  
  53.     public static void showDemo(Frame demoFrame)
  54.     {
  55.         demoFrame.setSize(550,500);
  56.         demoFrame.show();
  57.     }
  58.  
  59.     public void demoClosed()
  60.     {
  61.         demoFrame = null;
  62.     }
  63.  
  64.   public void actionPerformed(ActionEvent e) {
  65.     String arg = e.getActionCommand();
  66.     if (arg.equals("Demo")) {
  67.       demoButton.setLabel("loading");
  68.       if (demoFrame == null) {
  69.     demoFrame = createDemoFrame(this);
  70.     showDemo(demoFrame);
  71.       }
  72.       demoButton.setLabel("Demo");
  73.     }
  74.   }
  75.  
  76. }
  77.  
  78.